package ck.mmd.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import ck.mmd.bean.Type;
import ck.mmd.util.DaoUtils;

public class TypeDao {
	/**
	 * 通过自id查询类别
	 * @param id 自己的id
	 * @return
	 */
	public Type findTypeById(String id) {
		String sql = "select * from type where id = ?";
		try{
			QueryRunner runner = new QueryRunner(DaoUtils.getSource());
			return runner.query(sql,new BeanHandler<Type>(Type.class),id);
		}catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
}
